<%-- 
    Document   : smsType5
    Created on : 11 Jan, 2013, 7:00:58 PM
    Author     : sagar
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../common/script.jsp" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <%@include file="../common/title.jsp" %>

        <script type="text/javascript">
            var hospitalName;
            var hospitalInfo;
            var hospitalContactName;
            var specialistName;
            function EnableDisable(){
                
                var checkForLocum=document.getElementById("locumId").value;
                var checkForHospital=document.getElementById("hospitalId").value;
                //  var checkForAppSpecialist=document.getElementById("appSpecialistId").value;
                //var checkForSpecialist=document.getElementById("specialistId").value;
                var checkForDoctor=document.getElementById("doctorId").value;
                var checkForAmbulance=document.getElementById("ambulanceId").value;
                
                
                // FOR ENABLING AND DISABLING THE BODY OF SMSTYPE 5
                if(checkForLocum!='' && checkForHospital!=''){
                   
                    document.getElementById("smsType5").disabled=false;
                }else{
                    document.getElementById("smsType5").disabled=true;
                }
                
                // FOR ENABLING AND DISABLING THE BODY OF SMSTYPE 6
                if(checkForHospital!='' && checkForDoctor!='' && checkForAmbulance!=''){
                    document.getElementById("smsType6").disabled=false;
                }else{
                    document.getElementById("smsType6").disabled=true;
                }
                
                // FOR ENABLING AND DISABLING THE BODY OF SMSTYPE 7
                //if(checkForHospital!=''){
                //    document.getElementById("smsType7").disabled=false;
                //}else{
                //    document.getElementById("smsType7").disabled=true;
                //}
                
                // FOR ENABLING AND DISABLING THE BODY OF SMSTYPE 8
                if(checkForHospital!='' && checkForAmbulance!=''){
                    document.getElementById("smsType8").disabled=false;
                }else{
                    document.getElementById("smsType8").disabled=true;
                }
                
                // FOR ENABLING AND DISABLING THE BODY OF SMSTYPE 7 AND SMSTYPE 9
                if(checkForHospital!=''){
                    //document.getElementById("smsType8").disabled=false;
                    document.getElementById("smsType7").disabled=false;
                    document.getElementById("smsType9").disabled=false;
                }else{
                    //document.getElementById("smsType8").disabled=true;
                    document.getElementById("smsType7").disabled=true;
                    document.getElementById("smsType9").disabled=true;
                }
                
                
                // FOR ENABLING AND D   ISABLING THE BODY OF SMSTYPE 10
                if(checkForHospital!='' && checkForLocum!='' && checkForDoctor!='' && checkForAmbulance!='' ){
                    
                    document.getElementById("smsType10").disabled=false;
                }else{
                    
                    document.getElementById("smsType10").disabled=true;
                }

                
            
            }

           
            function selectSms(){
                
                var locumContact1;
                var locumContact2;
                
                //buliding smsbody for smsType5
                var msBody2=""; 
                var locumId=document.getElementById("locumId");
                var locumInfo = locumId.options[locumId.selectedIndex].text;
                locumName=locumInfo.replace(/[^A-Za-z]+/g, " ");
                locumContact1=locumInfo.replace(/[^0-9]+/g, " ");
                
                var msBody1="Dear "+locumName+", \n\
Patient Address : ${customer.address}\n\
Landmark :${customer.landmark}.\n\
Phone number :${customer.phone1}\n\
Chief complaint :${customer.cheifComplaint}.\n\
Preferred hospital :" + hospitalName +".\n\
Blood group :${customer.bloodGroup}\n\
Allergic to ${customer.food},${customer.drug},${customer.otherAllergies}\n\
Know illness :";
            <c:forEach items="${illnessList}" var="list">
                    msBody2+="${list.ILLNESS_NAME}"+",";
            </c:forEach>
                    var msBody3="\n\
Medico-legal :NA\n\
Call  86 555 89 555 if you require any information.";
                    var msBody5=msBody1.concat(msBody2,msBody3);
                    document.getElementById("smsType5").value=msBody5;
                    // end of SmsBody for SmsType=5
                    
                    //building SmsBody for SmsType=6
                    var doctorName=document.getElementById("doctorId").value;
                    
                    var ambulanceId=document.getElementById("ambulanceId");
                    var companyName = ambulanceId.options[ambulanceId.selectedIndex].text;
                    companyName=companyName.replace(/[^A-Za-z]+/g, " ")
                    //var companyName=document.getElementById("ambulanceId").value;
                    var msBody6="Dear ${customer.customerName}, Dr. "+doctorName+" is on his way to visit "+companyName+" ambulance service has been alerted." +hospitalName+" hospital has been alerted. For further help, please call 86 555 89 555.";
                    document.getElementById("smsType6").value=msBody6;
                    // end of SmsBody for SmsType=6
                    
                    // Building SmsBody For Sms Type7
                    var array_1= new Array();
                    var array_1 = hospitalInfo.split("~",4);
                    for (var i=0;i<array_1.length;i++){
                        //alert(array_1[2]);
                        hospitalContactName=array_1[2];
                    }

                    
                    
                    var msBody7="Dear "+hospitalContactName+", \n\
This is to confirm details of patient referred to you by Healthspring.\n\
${customer.customerName} is being moved to your hospital.\n\
Patient is complaining of ${customer.cheifComplaint}. \n\
Patient address: ${customer.address}. \n\
Please call  86 555 89 555  in case you need any information.";
                    document.getElementById("smsType7").value=msBody7;
                    // end of SmsBody for SmsType=7
                    
                    // Building SmsBody For Sms Type8
                    
                    var msBody8="Patient address: ${customer.address} Pincode :${customer.zipCodeArea.zipCode} Landmark:${customer.address} Patient phone number 1:${customer.phone1} Patient phone number 2:${customer.phone2}.To be admitted in:"+hospitalName+"";  
                    document.getElementById("smsType8").value=msBody8;           
                    //}else{
                    //   var msBody8="Patient address: ${customer.address} Pincode :${customer.zipCodeArea.zipCode} Landmark:${customer.address} Patient phone number 1:${customer.phone1} To be admitted in:"+hospitalName+"";
                    //   document.getElementById("smsType8").value=msBody8;
                    
                    // end of SmsBody for SmsType=8
                    
                    
                    // Building SmsBody For Sms Type9
                    var temp="";
                    var msBody9P1="Name of Patient admitted:${customer.customerName} \n\
Chief complaint:${customer.cheifComplaint}\n\
";
    
                    if(${customer.relation.relationId!=6}){
                        temp+="Name of ICICI employee: ${customerDetail.customerName}\n\
ICICI employee ID:${customerDetail.empId}\n\
";
    
                    }else{
                        temp+="Name of ICICI employee:${customer.customerName}\n\
ICICI employee ID:${customer.empId}\n\
";
                    }

                    var msBody9P2="Relation:${customer.relation.relationName}\n\
Hospital:"+hospitalName+"\n\
Please call 86 555 89 555 for further details.";
                    var msBody9=msBody9P1.concat(temp, msBody9P2);
                    
                    document.getElementById("smsType9").value=msBody9;
                    // end of SmsBody for SmsType=9
        
                    // Building SmsBody For Sms Type10
                    var locumId=document.getElementById("locumId").value;        
                    
        
       
                    var msBody10="Emergency Intimation\
Name of patient:${customer.customerName} \n\
Member type:${customer.paymentTypeId.paymentTypeName}\n\
Chief complaint:${customer.cheifComplaint} \n\
Hospital: "+hospitalName+"\n\
Name of Locum: "+locumName+"\n\
Phone number of Locum: "+locumContact1+"\n\
HS Doctor on call: "+doctorName+"\n\
Ambulance Service: "+companyName+"";
                    document.getElementById("smsType10").value=msBody10;
                    // end of SmsBody for SmsType=10
                    
                }     
    
                $(function() {
                    $( "#hospitalId" ).autocomplete({
                        source: "../ajaxCallForSMSHospitalList.htm",
                        minLength: 1,
                        select: function(event, ui) { 
                            hospitalInfo=ui.item.value;
                            //Replace 
                            //hospitalName=hospitalName.replace(/[^A-Za-z]+/g, " ");
                            hospitalName=hospitalInfo.split("~",1);
                        }
                    
                    });
                });
                
                //                $(function() {
                //                    $( "#appSpecialistId" ).autocomplete({
                //                        source: "../ajaxCallForAppSpecialist.htm",
                //                        minLength: 1,
                //                        select: function(event, ui) { 
                //                            exSpecialistName=ui.item.value;
                //                            //Replace
                //                            exSpecialistName=exSpecialistName.replace(/[^A-Za-z]+/g," ");
                //                
                //                        }
                //                    });
                //                });
               
                $(function() {
                    $( "#specialistId" ).autocomplete({
                        source: "../ajaxCallForSpecialist.htm",
                        minLength: 1,
                        select: function(event, ui) { 
                            specialistName=ui.item.value;
                            //Replace
                            //specialistName=specialistName.replace(/[^A-Za-z]+/g," ");
                
                        }
                    });
                });
   
        </script>

    </head>
    <body onload="selectSms();">
        <%@include file="../common/header.jsp" %>
        <%@include file="../common/menu.jsp" %>
        <div class="in_02">
            <form:form id="form1" name="form1"  method="POST">
                <fieldset style="width:90%;">
                    <legend>Sending SMS - In Case Of Emergency</legend>
                    <table class="formTable2" style="width:100%;">

                        <tr>
                            <td style="padding-right: 0"><spring:message code="locumName"/>:<br/>
                                <select  id="locumId" name="locumId"  class="userInputLarge" onchange="selectSms(this);EnableDisable(this);" onblur="selectSms(this);EnableDisable(this);">
                                    <option value="" label="-"></option>
                                    <c:forEach items="${locumList}" var="list">
                                        <option value="${list.locumName} ~ ${list.contact1}">${list.locumName} ~ ${list.contact1}</option>
                                    </c:forEach>
                                </select><br/>
                            </td>
                            <td style="padding-right:0">
                                <label>Hospital Name:</label><br />
                                <input type="text" name="hospitalId" id="hospitalId"  class="userInputLarge" onchange="selectSms(this);EnableDisable(this);" onblur="selectSms(this);EnableDisable(this);"/>
                            </td>
                            <%--
                                                    <td style="padding-right: 0">
                                                        <label>Exclusive Specialist Name:</label><br />
                                                        <input type="text" name="appSpecialistId" id="appSpecialistId"  class="userInputLarge" onchange="selectSms(this);EnableDisable(this);" onblur="selectSms();" />
                                                    </td>   

                            <td style="padding-right: 0">
                                <label> Specialist Name:</label><br />
                                <input type="text" name="specialistId" id="specialistId"  class="userInputLarge" onchange="selectSms(this);EnableDisable(this);" onblur="selectSms(this);EnableDisable(this);" />
                            </td>
                            --%>

                            <td style="padding-right: 0"><spring:message code="doctorName"/>:<br/>
                                <select  id="doctorId" name="doctorId"  class="userInputMedium" onchange="selectSms(this);EnableDisable(this);" onblur="selectSms(this);EnableDisable(this);">
                                    <option value="" label="-"></option>
                                    <c:forEach items="${doctorList}" var="list">
                                        <option value="${list.doctorName}">${list.doctorName} </option>
                                    </c:forEach>
                                </select> 
                            </td>
                            <td style="padding-right: 0"><spring:message code="ambulanceName"/>:<br/>
                                <select  id="ambulanceId" name="ambulanceId"  class="userInputMedium" onchange="selectSms(this);EnableDisable(this);" onblur="selectSms(this);EnableDisable(this);">
                                    <option value="" label="-"></option>
                                    <c:forEach items="${ambulanceList}" var="list">
                                        <option value="${list.companyName} ~ ${list.contact1}">${list.companyName} ~ ${list.contact1} </option>
                                    </c:forEach>
                                </select> 
                            </td>
                     
                        </tr>
                        <tr>
                            <td colspan="5">
                                <table class="formTableForSms"   cellPadding="0" cellSpacing="0">
                                    <tr>
                                        <td><span class="HeadingForSms"><b>Sent to Locum (doctor visiting the patient)</b></span><br/><br/>
                                            Message :<br/>
                                            <textarea id="smsType5" name="smsType5" disabled value="${msBody5}" class="TextAreaForSms" readonly></textarea>
                                        </td>
                                        <td><span class="HeadingForSms"><b>Sent to patient in case of emergency</b></span><br/><br/>
                                            Message :<br/>
                                            <textarea id="smsType6" name="smsType6" disabled  value="${msBody6}" class="TextAreaForSms" readonly></textarea>
                                        </td>
                                        <td><span class="HeadingForSms"><b>Sent to hospital in case of emergency hospitalisation</b></span><br/><br/>
                                            Message :<br/>
                                            <textarea id="smsType7" name="smsType7" disabled value="${msBody7}" class="TextAreaForSms" readonly></textarea>
                                        </td>
                                    </tr>
                                    <tr>

                                        <td><span class="HeadingForSms"><b>Sent to ambulance in case of emergency</b></span><br/><br/>
                                            Message :<br/>
                                            <textarea id="smsType8" name="smsType8" disabled value="${msBody8}" class="TextAreaForSms" readonly=""/></textarea><br/>
                                        </td>
                                        <td><span class="HeadingForSms"><b>Sent to ICICI Management & Shobana & Kavita</b></span><br/><br/>
                                            Message :<br/>
                                            <textarea id="smsType9" name="smsType9" disabled value="${msBody9}" class="TextAreaForSms" readonly=""></textarea>
                                        </td>
                                        <td><span class="HeadingForSms"><b>Sent to Healthspring Management</b></span><br/><br/>
                                            Message :<br/>
                                            <textarea id="smsType10" name="smsType10" disabled value="${msBody10}" class="TextAreaForSms" readonly=""></textarea>
                                        </td>

                                    </tr>


                                </table>
                            </td>
                        </tr>

                        <tr>

                            <td colspan="5" align="center">
                                <input type="submit" name="_finish"  value="<spring:message code="button.sendSms"/>" onclick=" validateForm();onSubmit();return yav.performCheck('form1', rules, 'inline'); "/>
                                <input type="submit" name="_cancel"  value="<spring:message code="button.Cancel"/>" onclick=" validateForm();onSubmit();return yav.performCheck('form1', rules, 'inline'); "/>
                            </td>
                        </tr>

                    </table>
                </fieldset>
            </form:form>
        </div>
    </body>
</html>
